<?php

namespace App\Http\Controllers;

abstract class BaseController extends Controller
{
    /**
     * @var string 程序版本
     */
    public $version = '0.0.1';

    const RESPONSE_HTTP_WORK_ORDER_SPECIAL_CODE = 208;   //【工单】前段判断类型弹窗使用

    public function json(array $data = [])
    {
        return response()->json($data)->header('Content-Type', 'application/json;charset=utf-8');
    }

    public function success(array $data = null)
    {
        return $this->json(['code' => 200, 'msg' => '', 'data' => $data ?: null]);
    }

    public function fail(int $code, string $msg = '', array $data = null)
    {
        return $this->json(['code' => $code, 'msg' => $msg, 'data' => $data ?: null]);
    }
}
